const mongoose = require('mongoose');
const { schedules } = require("./data/schedules.js")
const Schema = mongoose.Schema;
// 创建数据结构
//创建数据结构
const schedulesScheme = new Schema({
    movieId: {
        type: mongoose.Schema.Types.ObjectId,
        ref: "movies"
    },
    cinemasId: {
        type: mongoose.Schema.Types.ObjectId,
        ref: "cinemas"
    },
    theaterId: {
        type: mongoose.Schema.Types.ObjectId,
        ref: "theaters"
    },
    showTime: String,
    showDate: String,
    price: String,
 
});

 const schedulesModel = mongoose.model("schedules", schedulesScheme, "schedules");
 mongoose.connect("mongodb://tangzhenhua:Lovo123456@182.92.214.223:8084/maiwenjie",
 {
    useNewUrlParser: true,
    useUnifiedTopology: true,
    auth: { authSource: "admin" }
  },
 async () => {
    // 当连接成功后触发
    // 创建学生数据 一个（对象）或多个（数组）
    await schedulesModel.create(schedules)
})